package main

import "fmt"

func main() {
	prices := []int{1, 5, 2, 3, 1}
	fmt.Println(maxProfit(prices))
}

func maxProfit(prices []int) int {
	profit := 0
	for i := 0; i < len(prices)-1; i++ {
		if prices[i] < prices[i+1] {
			profit += prices[i+1] - prices[i]
		}
	}

	return profit
}
